from pydantic import BaseModel, Field


class DevOps(BaseModel):
    """运维对象"""
    name: str = Field(..., title='运维对象名称')
    type: str = Field(..., title='对象类型')

    @property
    def aa(self):
        return f'{self.name}_{self.type}'


class DevOpsServer(BaseModel):
    """服务器"""
    machine_root: str = Field('', title='机房')
    ip: str = Field('', title='服务器IP')


class DevOpsService(BaseModel):
    """服务"""
    ip: str = Field('', title='ip')
    node_ip: str = Field('', title='节点IP')
    node_port: int = Field(None, title='服务端口')


if __name__ == '__main__':
    s_dev = DevOps(name='c', type='aa')
    d = s_dev.dict()
    print(d)
